package com.zyd.shiro.persistence.mapper;


import com.zyd.shiro.business.entity.PurchaseLine;
import com.zyd.shiro.persistence.beans.PakPurchaseLine;
import com.zyd.shiro.plugin.BaseMapper;
import com.zyd.shiro.framework.object.BaseConditionVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;



@Repository
public interface PakPurchaseLineMapper extends BaseMapper<PakPurchaseLine> {

/**
     * 分页查询
     *
     * @param vo
     * @return
     */
    @Select("<script>"+
            "SELECT s.* FROM PAK_PURCHASE_LINE s WHERE " +
            "<choose>"+
            "<when  test='sub != 0 ' >" +
            " s.purchase = #{sub , jdbcType=BIGINT}" +
            "</when >"+
            "<otherwise>"+
            " 1=2 "+
            "</otherwise>"+
            "</choose>"+
            " GROUP BY s.id ORDER BY s.create_time DESC " +
            "</script>")
    List<PakPurchaseLine> findPageBreakByCondition(BaseConditionVO vo);

    @Select("<script>"+
            "SELECT s.* FROM PAK_PURCHASE_LINE s WHERE " +
            "<choose>"+
            "<when  test='purchaseId != 0 ' >" +
            " s.purchase = #{purchaseId , jdbcType=BIGINT}" +
            "</when >"+
            "<otherwise>"+
            " 1=2 "+
            "</otherwise>"+
            "</choose>"+
            " GROUP BY s.id ORDER BY s.create_time DESC " +
            "</script>")
    List<PakPurchaseLine> findByPurchase(@Param(value = "purchaseId") Long purchaseId);
}